package com.yesep.learn.design.behavioral.observer;

import java.util.*;

public class SubscriptionSubject implements ISubject {
    private final List<IObserver> observers = new ArrayList<>();

    @Override
    public void register(IObserver observer) {
        observers.add(observer);
    }

    @Override
    public void unregister(IObserver observer) {
        observers.remove(observer);
    }

    @Override
    public void notify(String message) {
        for (IObserver observer : observers) {
            observer.update(message);
        }
    }
}
